<?php

require('config.php');

if(!isset($_SESSION['id_user'])){
	redirectFront('connexion');
}
if(isset($_SESSION['id_property'])){
	$language_link = $_SESSION['id_property'];
}else{
	$language_link = isset($_GET['id'])?$_GET['id']:0;
}
$page = new rootLayoutPage();
$page->addJavaScript('jQuery.calendar.js');
$page->addStyleSheet('jquery-calendar.css');
$page->addJavaScript('keyEnable.js');
$page->addJavaScript('jQuery.AjaxSelect.js');
$page->addJavaScript('jQuery.AjaxForm.js');
$page->addJavaScript('jQuery.URLcontent.location.map.address.js');
$page->addJavaScript('jQuery.autoLand.price.area.js');

//$page->addJavaScript('jQuery.place.js');
//$page->setPageSameLevel($category_map->id_menu_left_tree);
//-- Menu Page ----------------------------------------------//
$page->setBaliseTitle('place_balise');
$page->setDescription('place_description');
$xml = tmxTranslate('place-create.xml', REP_XLAT_TEMPLATE);
$xml_subject = tmxTranslate('subject.mail.xml', REP_XLAT_MAIL);
$xml_url_rewrite = tmxTranslate('url_content_location_map_address.xml', REP_XLAT_SCRIPT);

$menu = new layoutMenuLeft();
	$menuPage = new layoutMenuPage();
	$menuPage->setTable('category_map');
	//$menuPage->setIdShow($category_map->id_menu_left_tree);
	//$menu->setIdShow($category_map->id_menu_left_tree);
	$menu->pushMenu($menuPage);

//--------Menu indicator--------------//
$menuIndictor = new layoutMenuIndicator();
	//$menuIndictor->idTree($category_map->id_menu_left_tree);
	//$menuIndictor->title($category_map->title);
	$page->setMenuIndicator($menuIndictor);

//************************//

	if($language_link!=null && $language_link>0){
		if(onlyNumber($language_link)){//Check User in Group Admin for this location//
			$location = modelLocationMap::getMyLocationList($_SESSION['id_user'],$language_link);
			if(!$location){if(!modelUser::isUserGroupAdmin($_SESSION['id_user'])){redirectFront(LANGUAGE_FOLDER."/my-location");}}
		}else{redirectFront(LANGUAGE_FOLDER."/my-location");}
		$location_map = modelLocationMap::getList($language_link);
	}

//************************//
	$space = " ";
	$full_text = "";
	/***** keyword for full text ******/
	$listKey = modelKeyWord::getList();
	foreach($listKey as $key => $k){
		if(isset($_POST['k'.$k->language_link])){
			$full_text .= $k->title.$space;
		}
	}
	$list_c_ = modelMap::getListCategory();
	foreach($list_c_ as $k => $c){
		if(isset($_POST['c'.$c->language_link])){
			$full_text .= $c->title.$space;
		}
	}
	if(isset($_POST['Create'])) {
		 try {
				  $name_place = addslashes(trim($_POST['place_name']));
				  $full_text .= $name_place.$space;
				  $address = addslashes(trim($_POST['address']));
				  $full_text .= $address.$space;
				  $id_province = addslashes(trim($_POST['province']));
				  $id_district = addslashes(trim($_POST['district']));
				  $full_text .= addslashes(trim($_POST['hidden_type_real_text'])).$space;
				  $full_text .= addslashes(trim($_POST['hidden_province_text'])).$space;
			
				  $price_rental = floatval($_POST['price_rental']);
				  $price_sell = floatval($_POST['price_sell']);
			
				  $length = floatval($_POST['length']);
				  $width = floatval($_POST['width']);
				  $height = floatval($_POST['height']);
			
				  $size_building = floatval($_POST['size_building']);
				  $length_land = floatval($_POST['length_land']);
				  $width_land = floatval($_POST['width_land']);
				  $size_land = floatval($_POST['size_land']);
				  $bedroom = floatval($_POST['bedroom']);
				  $bathroom = floatval($_POST['bathroom']);
				  $mezzanine = $_POST['mezzanine'];
				  if($mezzanine==null)$mezzanine=0;
				  else $mezzanine =1;
				  $floor = $_POST['floor'];
				  $number_floor = $_POST['number_floor'];
				  $tenant = $_POST['tenant'];
				  if($tenant==null)$tenant=0;
				  else $tenant =1;
				  if($_POST['end_tenant']!=""){
				    $end_tenant = addslashes($_POST['end_tenant']);
				    $date_ajout = explode('/', $end_tenant);
				    $end_tenant = mktime(0, 0, 0, $date_ajout[1], $date_ajout[0], $date_ajout[2]);
				 }else{
					$end_tenant = 0;
				 }
			
				 $end_tenant = $tenant==1?$end_tenant:'';
			
			
				 if($_POST['start_date']!=""){
				    $start_date = addslashes($_POST['start_date']);
				    $date_ajout = explode('/', $start_date);
				    $start_date = mktime(0, 0, 0, $date_ajout[1], $date_ajout[0], $date_ajout[2]);
				 }else{
					$start_date = 0;
				 }
				 
				 if($_POST['end_date']!=""){
				    $end_date = addslashes($_POST['end_date']);
				    $date_ajout = explode('/', $end_date);
				    $end_date = mktime(0, 0, 0, $date_ajout[1], $date_ajout[0], $date_ajout[2]);
				 }else{
					$end_date = 0;
				 }
				 
				$full_text .= $mezzanine>0?addslashes(trim($_POST['hidden_mezzanine_text'])).$space:'';
				$full_text .= $tenant>0?addslashes(trim($_POST['hidden_tenant_text'])).$space:'';
			
			
				$furnished_apartment = isset($_POST['furnished_apartment'])?1:0;
				$furnished_detail = $furnished_apartment==1?addslashes(trim($_POST['furnished_detail'])):'';
				$full_text .= $furnished_apartment>0?addslashes(trim($_POST['hidden_furnished_apartment_text'])).$space:'';
				$full_text .= $furnished_detail.$space;
	  			$comment = addslashes(trim($_POST['comment']));
	  			
				  $latitude = '';
				  $longitude = '';
				$content = addslashes(trim($_POST['content']));
				$full_text .= $content.$space;
				  $language_code = $_POST['language_code'];
			
				  $index = isset($language_link)?(isset($_POST['index'])?1:0):1;
				  $follow = isset($language_link)?(isset($_POST['follow'])?1:0):1;
			
				  $url_rewriting = addslashes($_POST['url_rewriting_post']);
				  $meta_title = addslashes($_POST['meta_title_post']);
				  $meta_description = addslashes($_POST['meta_description_post']);
			if (isset($_COOKIE['placeCreat'])){
			 $xml = tmxTranslate('url_city.xml', REP_XLAT_SCRIPT);
				$language_link = isset($_POST['language_link'])?($_POST['language_link']):(isset($_SESSION['id_property'])?$_SESSION['id_property']:'0');
				$user = modelUser::getProfil($_SESSION['id_user']);
				$visible = 0;
				if($user){
					$count = modelLocationMap::countMyLocationVisible();
					if($user->total_credit > $count->count_credit){
						$visible = 1;
					}
				}
				
				$boo = false;
				//*** Create map ********************************************//
				if(!modelLocationMap::getExistPlace($language_link)){//Create new property
					$id = modelLocationMap::insertAddressMarker($name_place,$address,$language_link,$language_code,$visible,$content,$furnished_detail,$url_rewriting,$meta_title,$meta_description,1,$comment,$full_text);
					$id_shared = modelLocationMap::insertPlaceShared($id_province,$id_district,$latitude,$longitude,$length,$width,$height,$length_land,$width_land,$size_building,$size_land,$bedroom,$bathroom,$mezzanine,$furnished_apartment,$floor,$number_floor,$tenant,$end_tenant,$start_date,$end_date,$follow,$index);
					$id_price = modelLocationMap::insertPlacePrice($language_link,$price_rental,$price_sell,$rental_commission,$sale_price_owner);
					modelLocationMap::updatePriceLanguageLink($id_price);
					modelLocationMap::updateSharedPriceLink($id,$language_link,$id_shared,$id_price);
					$_SESSION['id_property'] = $id;
					$boo = true;
				}else{//For Update property have SESSION property
					$boo = false;
					modelLocationMap::update_front($language_link,$name_place,$address,$content,$furnished_detail,$url_rewriting,$meta_title,$meta_description,1,$comment,$full_text);
					$getPlace = modelLocationMap::getPlaceById($language_link);
					$id_map_address_shared = $getPlace->id_map_address_shared;
					$id_map_address_price = $getPlace->id_map_address_price;
					$id_map_address = $getPlace->id_map_address;
					modelLocationMap::updatePlaceShared_front($id_map_address_shared,$id_province,$id_district,$length,$width,$mezzanine,$furnished_apartment,$floor,$number_floor,$tenant,$end_tenant,$start_date,$end_date,$index,$follow,$height,$length_land,$width_land,$size_building,$size_land,$bedroom,$bathroom);
					
					modelLocationMap::clearPlacePrice($id_map_address_price);
					$id_price = modelLocationMap::insertPlacePrice($id_map_address_price,$price_rental,$price_sell,$rental_commission,$sale_price_owner);
					modelLocationMap::updateSharedPriceLink($id_map_address_shared,$language_link,$id_map_address_shared,$id_price);
					//****************************************//
				}
				
				//***********************************************************//
				if(!isset($_POST['language_link'])){
					$id = $language_link?$language_link:$id;
					modelLocationMap::updateLanguageLink($id);
					$language_link = $id;
				}
				if($boo == true){
					foreach($list_c_ as $k => $c){
						if(isset($_POST['c'.$c->language_link])){
							$id_category = $_POST['c'.$c->language_link];
							modelLocationMap::linkLocationCategorymap($id_category,$language_link);
						}
					}
					//=======keyword========//
					foreach($listKey as $key => $k){
						if(isset($_POST['k'.$k->language_link])){
							$position = modelKeyWord::getOrdre($language_link)->position+10;
							$id_key = $_POST['k'.$k->language_link];
							modelKeyWord::insertKeywordProperty($language_link,$id_key,$position);
						}
					}
					modelRealEstate::linkRealEstateTypeMap($language_link,$_POST['type_real']);
				}else{
					modelMap::clearCategoryLocationMap($language_link);
					foreach($list_c_ as $k => $c){
						if(isset($_POST['c'.$c->language_link])){
							$id_category = $_POST['c'.$c->language_link];
							modelLocationMap::linkLocationCategorymap($id_category,$language_link);
						}
					}
					//=======keyword========//
					modelKeyWord::clearKeywordProperty($language_link);
					foreach($listKey as $key => $k){
						if(isset($_POST['k'.$k->language_link])){
							$position = modelKeyWord::getOrdre($language_link)->position+10;
							$id_key = $_POST['k'.$k->language_link];
							modelKeyWord::insertKeywordProperty($language_link,$id_key,$position);
						}
					}
					modelRealEstate::clearRealEstateTypeMap($language_link);
					modelRealEstate::linkRealEstateTypeMap($language_link,$_POST['type_real']);
				}

				$user = modelUser::getProfil($_SESSION['id_user']);
				$mail = new flyLayout(REP_MAIL.'place.mail.tpl');
				$mail->start();
				$mail->setVariable('email', $user->login);

				$lang = $_SESSION['language_code']==language_default?'':'&language='.$_SESSION['language_code'];
				$mail->setVariable('link_detail', 'http://'.$_SERVER['HTTP_HOST'].LANGUAGE_FOLDER.'/place_detail.php?id='.$language_link.'&view');
				$mail->setVariable('link_validation', 'http://'.$_SERVER['HTTP_HOST'].'/'.REP_MONSTER.'content/content_location_map_detail.php?id='.$language_link.$lang);

				$mail->stop();

				$subject = $xml_subject['place'];
				setcookie ("placeCreat", "", time() - 3600);
				setcookie ("id_link", $language_link);
				unset($_COOKIE['placeCreat']);
				if($boo == true){// For send mail to webmaster when create property
					if(STATUS_EMAIL == 0) {
			    		echo $mail;
			    		die();
			    	}elseif(STATUS_EMAIL == 1) {
			    		monsterMail(MAIL_WEBMASTER, $subject, $mail);
			    	}else {
			    		echo $mail;
			    		monsterMail(MAIL_WEBMASTER, $subject, $mail);
			    	}
				}

				Persistence::register(PERSIST_MESSAGE, new Message(isset($xml['message_1'])?$xml['message_1']:'', Message::INFO));
				redirectFront('place-marker','id='.$language_link);
			 }else{
			 	$language_link = $_COOKIE['id_link'];
			 	setcookie ("id_link", "", time() - 3600);
				unset($_COOKIE['id_link']);
			 	redirectFront('place-marker','id='.$language_link);
			 }
		}
	    catch(Exception $e) {
	    	echo $e ;
	        Persistence::register(PERSIST_MESSAGE, new Message($e->getMessage(), Message::AVERT));
	    }

	}
	if(isset($_POST['Modify'])){
		$full_text = "";
				  $space = " ";
				  $name_place = addslashes(trim($_POST['place_name']));
				  $full_text .= $name_place.$space;
				  $address = addslashes(trim($_POST['address']));
				  $full_text .= $address.$space;
				  $id_province = addslashes(trim($_POST['province']));
				  $id_district = addslashes(trim($_POST['district']));
				  $full_text .= addslashes(trim($_POST['hidden_type_real_text'])).$space;
				  $full_text .= addslashes(trim($_POST['hidden_province_text'])).$space;
			
				  $price_rental = floatval($_POST['price_rental']);
				  $price_sell = floatval($_POST['price_sell']);
			      $rental_commission = $location_map->rental_commission;
			      $sale_price_owner = $location_map->sell_price_owner;
			
				  $length = floatval($_POST['length']);
				  $width = floatval($_POST['width']);
				  $height = floatval($_POST['height']);
			
				  $size_building = floatval($_POST['size_building']);
				  $length_land = floatval($_POST['length_land']);
				  $width_land = floatval($_POST['width_land']);
				  $size_land = floatval($_POST['size_land']);
				  $bedroom = floatval($_POST['bedroom']);
				  $bathroom = floatval($_POST['bathroom']);
				  $mezzanine = (isset($_POST['mezzanine']))?1:0;
				  $floor = $_POST['floor'];
				  $number_floor = $_POST['number_floor'];
				  $tenant = (isset($_POST['tenant']))?1:0;
				  
				  if(isset($_POST['end_tenant'])){
				    $end_tenant = addslashes($_POST['end_tenant']);
				    $date_ajout = explode('/', $end_tenant);
				    $end_tenant = mktime(0, 0, 0, $date_ajout[1], $date_ajout[0], $date_ajout[2]);
				 }else{
					$end_tenant = 10;
				 }
				 $end_tenant = $tenant==1?$end_tenant:'';
			
				 if($_POST['start_date']!=""){
				    $start_date = addslashes($_POST['start_date']);
				    $date_ajout = explode('/', $start_date);
				    $start_date = mktime(0, 0, 0, $date_ajout[1], $date_ajout[0], $date_ajout[2]);
				 }else{
					$start_date = 0;
				 }
				 
				 if($_POST['end_date']!=""){
				    $end_date = addslashes($_POST['end_date']);
				    $date_ajout = explode('/', $end_date);
				    $end_date = mktime(0, 0, 0, $date_ajout[1], $date_ajout[0], $date_ajout[2]);
				 }else{
					$end_date = 0;
				 }
				 
				$full_text .= $mezzanine>0?addslashes(trim($_POST['hidden_mezzanine_text'])).$space:'';
				$full_text .= $tenant>0?addslashes(trim($_POST['hidden_tenant_text'])).$space:'';
			
			
				$furnished_apartment = isset($_POST['furnished_apartment'])?1:0;
				$furnished_detail = $furnished_apartment==1?addslashes(trim($_POST['furnished_detail'])):'';
				$full_text .= $furnished_apartment>0?addslashes(trim($_POST['hidden_furnished_apartment_text'])).$space:'';
				$full_text .= $furnished_detail.$space;
	  			$comment = addslashes(trim($_POST['comment']));
	  			
				  $latitude = '';
				  $longitude = '';
				$content = addslashes(trim($_POST['content']));
				$full_text .= $content.$space;
				  $language_code = $_POST['language_code'];
			
				  $index = isset($language_link)?(isset($_POST['index'])?1:0):1;
				  $follow = isset($language_link)?(isset($_POST['follow'])?1:0):1;
			
				  $url_rewriting = addslashes($_POST['url_rewriting_post']);
				  $meta_title = addslashes($_POST['meta_title_post']);
				  $meta_description = addslashes($_POST['meta_description_post']);
		modelLocationMap::update_front($location_map->id_map_address,$name_place,$address,$content,$furnished_detail,$url_rewriting,$meta_title,$meta_description,1,$comment,$full_text);
		$getPlace = modelLocationMap::getPlaceById($language_link);
		$id_map_address_shared = $getPlace->id_map_address_shared;
		$id_map_address_price = $getPlace->id_map_address_price;
		modelLocationMap::updatePlaceShared_front($id_map_address_shared,$id_province,$id_district,$length,$width,$mezzanine,$furnished_apartment,$floor,$number_floor,$tenant,$end_tenant,$start_date,$end_date,$index,$follow,$height,$length_land,$width_land,$size_building,$size_land,$bedroom,$bathroom);
		$id_price = modelLocationMap::insertPlacePrice($id_map_address_price,$price_rental,$price_sell,$rental_commission,$sale_price_owner);

		modelRealEstate::updateRealEstateTypeMap($_POST['type_real'],$language_link);

		$list_c_ = modelMap::getListCategory();
		modelMap::clearCategoryLocationMap($language_link);
			foreach($list_c_ as $k => $c){
				if(isset($_POST['c'.$c->language_link])){
					$id_category = $_POST['c'.$c->language_link];
					modelLocationMap::linkLocationCategorymap($id_category,$language_link);
				}
			}

		$listKey = modelKeyWord::getList();
		modelKeyWord::clearKeywordProperty($language_link);
			foreach($listKey as $key => $k){
				if(isset($_POST['k'.$k->language_link])){
					$position = modelKeyWord::getOrdre($language_link)->position+10;
					$id_key = $_POST['k'.$k->language_link];
					modelKeyWord::insertKeywordProperty($language_link,$id_key,$position);
				}
			}

		Persistence::register(PERSIST_MESSAGE, new Message($xml['message_2'], Message::INFO));
		$html_name = $url_rewriting.'-'.$language_link.'.html';
		redirectFrontHtml($html_name);
	}


$tpl_file = 'place-create.tpl';
$place = new flyLayout(REP_TPL . $tpl_file);
$place->start();
setcookie("placeCreat","placeCreat");
$place->setVariable('txt_sms_building_area', $xml['txt_sms_building_area']);
	if($language_link>0){
		$location_map = modelLocationMap::getList($language_link);
		//$place->setVariable('checked_visible', $location_map->visible?'checked=checked':'');
		//$place->setVariable('language_link', $location_map->language_link);
		$place->setVariable('place_name', htmlspecialchars($location_map->name_place));
		$place->setVariable('address', htmlspecialchars($location_map->address));
		//$place->setVariable('map_province', addslashes($location_map->name_province));
		$place->setVariable('content', htmlspecialchars($location_map->content));
		
		$place->setVariable('price_rental', $location_map->price_rental);
		$place->setVariable('length', $location_map->length);
		$place->setVariable('width', $location_map->width);
		$place->setVariable('height', $location_map->height);

		$place->setVariable('price_sell', $location_map->price_sell);
		$place->setVariable('size_building', $location_map->size_building);
		$place->setVariable('length_land', $location_map->length_land);
		$place->setVariable('width_land', $location_map->width_land);
		$place->setVariable('size_land', $location_map->size_land);
		$place->setVariable('bedroom', $location_map->bedrooms);
		$place->setVariable('bathroom', $location_map->bathrooms);
		$place->setVariable('comment', $location_map->comment);
		$place->setVariable('checked_mezzanine', $location_map->mezzanine?'checked="checked"':'');
		$place->setVariable('checked_furnished_apartment', $location_map->furnished_apartment?'checked="checked"':'');
		$place->setVariable('furnished_detail', $location_map->furnished_detail);
		$place->setVariable('floor', $location_map->floor);
		$place->setVariable('number_floor', $location_map->number_floor);
		$place->setVariable('checked_tenant', $location_map->tenant?'checked="checked"':'');
		$end_tenant = $location_map->end_tenant!=0?date("d/m/Y",$location_map->end_tenant):'';
		$place->setVariable('end_tenant', $end_tenant?$end_tenant:'');
		$start_date = $location_map->start_date!=0?date("d/m/Y",$location_map->start_date):'';
		$place->setVariable('start_date', $start_date?$start_date:'');
		$end_date = $location_map->end_date!=0?date("d/m/Y",$location_map->end_date):'';
		$place->setVariable('end_date', $end_date?$end_date:'');
		$place->setVariable('language_code', $location_map->language_code);
		$place->setVariable('checked_index', $location_map->index?'checked="checked"':'');
		$place->setVariable('checked_follow', $location_map->follow?'checked="checked"':'');
		$place->setVariable('id_language_link',$_GET['id']);
	}
	$place->setVariable('url_rewriting', $xml_url_rewrite['url']);
	$place->setVariable('meta_title', $xml_url_rewrite['meta_title']);
	$place->setVariable('meta_description', $xml_url_rewrite['meta_description']);
	$place->setVariable('currency', CURRENCY);


		$place->setVariable('language_code',$_SESSION['language_code']);

	//==========Provicne============
		$getProvince=modelProvince::getListProvince($_SESSION['language_code']);
		foreach($getProvince as $key => $province) {
			$place->setVariable('province',$province->title);
			$place->setVariable('id_province',$province->language_link);
			if($language_link>0){
				$place->setVariable('selected_province',($location_map->id_province == $province->language_link)?'selected=true':'');
			}			
			$place->parseList('list_name_province');
		}	
	//==========Provicne============
		$listdistrict = modelDistrict::getListDistrict($_SESSION['language_code']);
		foreach($listdistrict as $key => $district) {
			$place->setVariable('district',$district->title);
			$place->setVariable('id_district',$district->language_link);
			if($language_link>0){
				$place->setVariable('selected_district',($location_map->id_district == $district->language_link)?'selected=true':'');
			}			
			$place->parseList('list_name_district');
		}

	//======================
	if($language_link>0){
		$getTypeReal=modelRealEstate::getLocationMapRealEstate($language_link)->nextObject();
		$id_real = $getTypeReal->id_real_estate_type ;
	}
	$place->setVariable('selected_default',isset($language_link)?'':'selected="true"');
	$getReal=modelLocationMap::getListTypeReal();
		foreach($getReal as $key => $real) {
			$place->setVariable('real_title',$real->title);
			$place->setVariable('id_real_estate_type',$real->language_link);
			if($language_link>0){
				$place->setVariable('selected_real',$id_real==$real->language_link?'selected="true"':'');
			}
			$place->parseList('list_real_type');
		}

	//===========list category==============

	if(isset($language_link)){
		$getCategory=modelMap::getListCategoryTest($language_link,null,2);
		foreach($getCategory as $key => $category) {
			$place->setVariable('category_title',$category->title);
			$place->setVariable('id_category_map',$category->language_link);
			$place->setVariable('checked',$category->link==$category->language_link?'CHECKED="CHECKED"':'');
			$place->parseList('list_category');
		}
	}else{
		$getCategory=modelMap::getListCategory(2);
		foreach($getCategory as $key => $category) {
			$place->setVariable('category_title',$category->title);
			$place->setVariable('id_category_map',$category->language_link);
			$place->setVariable('checked','');
			$place->parseList('list_category');
		}
	}

	//==============list keyword==============
	//$listKeyWord = modelKeyWord::getList();
	$listKeyWord = modelKeyWord::getKeywordLinkProperty($language_link);
		if($listKeyWord->size()>0) {
			foreach($listKeyWord as $index => $keyword){
					$place->setVariable('title1', $keyword->title);
					$place->setVariable('key_link_1', $keyword->language_link);
					if($language_link>0){
						$place->setVariable('checked_key1',$keyword->link==$keyword->language_link?'CHECKED="CHECKED"':'');
					}
					$place->parseList('listkeyword_1');
			}
		}

	//$place->setVariable('rep_ajax', REP_AJAX);
	if(isset($_SESSION['id_property']) or $language_link){
		if($language_link>0){
			$place->setVariable('button_value',$xml['button_1']);
			$place->setVariable('button_id',$language_link);
			$place->showBlock('button_1');
		}else{
			$place->setVariable('button_value',$xml['button_2']);
			$place->setVariable('button_id','');
			$place->showBlock('button_2');
		}
	}else{
		$place->setVariable('button_value',$xml['button_2']);
			$place->setVariable('button_id','');
	}
	//$place->setVariable('button_value', isset($_SESSION['id_property'])==''?($language_link>0?$xml['button_1']:$xml['button_2']):$xml['button_2']);
	//$place->setVariable('button_id', isset($_SESSION['id_property'])==''?($language_link>0?$language_link:''):'');
	//$language_link>0?$place->showBlock('button_1'):$place->showBlock('button_2');

$place->stop();
$page->setBody($place);
$page->display();

?>